package com.translation.assistant.utils

object SensitiveWordsCheck {
    private var sensitiveWords: MutableList<String> = arrayListOf(
        "习近平",
        "習近平",
        "xijinping",
        "jinping",
        "xjp is",
        "xjp's",
        "xi is",
        "xi's",
        "china president xi",
        "xijinping's",
        "jinping's",
        "xi jin ping",
        "xi jinping"
    )

    fun setSensitiveWords(words: MutableList<String>?){
        sensitiveWords.clear()
        if(words != null){
            sensitiveWords.addAll(words)
        }
    }

    fun getSensitiveWords(): MutableList<String>{
        return sensitiveWords
    }

    /**
     * 文本中是否存在违规字符
     */
    fun isViolated(text: String?): Boolean {
        if(text == null)return false
        sensitiveWords.forEach { word ->
            if(word.isNotEmpty() && text.toUpperCase().contains(word.toUpperCase())){
                return true
            }
        }

        return false
    }

}